__global__ void computeVector (unsigned char* image, float* vector, float* parameters, int width, int dim) {

    int pos, x, y;
    int i = 0, index = threadIdx.x;

    /* we allocate Gaussian parameters in shared memory */
    __shared__ float par [DIM_PAR];

    /* the first thread will load the parameters */
    if (index == 0)
        for (i = 0; i < DIM_PAR; ++i)
            par[i] = parameters[i];

    /* we calculate right index and the coordinates of the point */
    pos = blockIdx.x * DIM_BLOCK + index;

    /* if the calculated index is rigth we work */
    if (pos < dim ) {
        x = (pos + 1) % width;
        y = (pos + 1) / width;
        vector[pos] = image[pos] - evaluateGaussian (&par[PAR_A], x, y);
    }
}